let inp = document.querySelector('#inp');
 let ul = document.querySelector('#ul');
 let a=document.querySelector('.iup>a')

 inp.oninput = function(){
   let key = this.value;

   let script = document.createElement('script');
   script.src = `https://suggest.taobao.com/sug?code=utf-8&q=${key}&extras=1&area=c2c&bucketid=atb_search&pid=mm_26632258_3504122_32538762&unid=&clk1=1fad8222a77ee4079bd26b9de8638f2c&_=1635158243300&callback=jsonp1`
   
   script.setAttribute('index','jsonp');
   let scriptAll = document.querySelectorAll('script');
   for(let i = 0; i<scriptAll.length;i++){
     if(scriptAll[i].getAttribute('index') == 'jsonp'){        
       document.body.removeChild(scriptAll[i]);
     }
   }
   window.jsonp1 = function (res){
     let str = '';
     if(res.result){ 
       res.result.forEach(item=>{
         str += `<li>${item[0]}</li>`
       })
       ul.innerHTML = str;
       ul.style.display = 'block';
      //  ul.style.border='1px solid #ccc';
       document.body.removeChild(script);
     }else{
       ul.innerHTML = '';
       ul.style.display = 'none';
     }
   }
   document.body.appendChild(script);
 }
 inp.onblur=function(){
  ul.style.display = 'none';
 }

 a.onclick=()=>{
  inp.value=''
 }
